package com.google.code.bankagregator.core.entityServices;

import com.google.code.bankagregator.dao.CreditDAO;
import com.google.code.bankagregator.entities.Credit;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import java.util.List;

/**
 * Credit Service
 */
@Stateless
public class CreditService {

    @EJB
    CreditDAO creditDAO;

    public void createCredit(Credit credit) {
        creditDAO.create(credit);
    }

    public Credit loadCredit(int creditId) {
        Credit credit = null;
        credit = creditDAO.getById(creditId);
        return credit;
    }

    public void updateCredit(Credit credit) {
        creditDAO.update(credit);
    }

    public void deleteCredit(int creditId) {
        creditDAO.delete(creditId);
    }

    public void deleteCredit(Credit credit) {
        creditDAO.delete(credit);
    }

    public List<Credit> getAllCredits() {
        List<Credit> credits = null;
        credits = creditDAO.getAll();
        return credits;
    }
}
